using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAL;

namespace BUS
{
    public class tbdoanhnghiepBUS
    {
        static public string error = "";
        public static void Insert(tbdoanhnghiepDTO dn)
        {
            tbdoanhnghiepDAL tbdoanhnghiepDAL = new tbdoanhnghiepDAL();
            tbdoanhnghiepDAL.Insert(dn);
        }
        public static void Update(tbdoanhnghiepDTO dn)
        {
            tbdoanhnghiepDAL tbdoanhnghiepDAL = new tbdoanhnghiepDAL();
            tbdoanhnghiepDAL.Update(dn);
            error = tbdoanhnghiepDAL.error;
        }
        public static void Delete(int iD)
        {
            tbdoanhnghiepDAL tbdoanhnghiepDAL = new tbdoanhnghiepDAL();
            tbdoanhnghiepDAL.Delete(iD);
        }
        public static tbdoanhnghiepDTOColection GET(string Where, int PageIndex, int PageSize,
                                        string OrderBy, string OrderDirection,
                                        out int TotalRecords)
        {
            tbdoanhnghiepDAL tbdoanhnghiepDAL = new tbdoanhnghiepDAL();
            return tbdoanhnghiepDAL.GET(Where, PageIndex, PageSize,
                            OrderBy, OrderDirection, out TotalRecords);
        }
        public static tbdoanhnghiepDTOColection GETAll()
        {
            int t = 0;
            tbdoanhnghiepDAL tbdoanhnghiepDAL = new tbdoanhnghiepDAL();
            return tbdoanhnghiepDAL.GET("where 1=1", 0, 10, tbdoanhnghiepDTOColumn.Tendn.ToString(), "ASC", out t);
        }
        public static tbdoanhnghiepDTO GetByID(int iD)
        {
            int t = 0;
            tbdoanhnghiepDAL tbdoanhnghiepDAL = new tbdoanhnghiepDAL();
            tbdoanhnghiepDTOColection spcolect = tbdoanhnghiepDAL.GET("where " + tbdoanhnghiepDTOColumn.Madn.ToString() + " = " + iD.ToString(), 0, 0,
                tbdoanhnghiepDTOColumn.Tendn.ToString(), "ASC", out t);
            if (spcolect.Count == 1)
                return spcolect[0];
            return null;
        }
        public static tbdoanhnghiepDTOColection getdoanhnghiep(int id)
        {
            int t = 0; 
            tbdoanhnghiepDAL tbdoanhnghiepDAL = new tbdoanhnghiepDAL();
            return tbdoanhnghiepDAL.GET("where " + tbdoanhnghiepDTOColumn.Madn.ToString() + " = " + id.ToString(), 0, 0,
            tbdoanhnghiepDTOColumn.Tendn.ToString(), "ASC", out t);
        }
    }
}
